package com.hctforgreen.greenservice;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.jpush.android.api.JPushInterface;

import com.hctforgreen.greenservice.ui.widget.PatchedTextView;
import com.hctforgreen.greenservice.utils.ThemeStoreUtil;

/**
 * 推送消息详情页
 * 
 * @author dhbing
 * 
 */
public class PushMessageActivity extends ParentActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_message_detail);
		initSkinLayout();
		initTitleButtonBar();
		initWindow();
	}


	private void initTitleButtonBar() {
		final TextView titleTv = (TextView) findViewById(R.id.tv_title);
		titleTv.setText(getString(R.string.message_detail_title_hint));

		final ImageButton backBtn = (ImageButton) findViewById(R.id.btn_back);
		backBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	private void initWindow() {
		final LinearLayout loadLyt = (LinearLayout) findViewById(R.id.lyt_default_load);
		final LinearLayout reloadLyt = (LinearLayout) findViewById(R.id.lyt_default_reload);

		loadLyt.setVisibility(View.GONE);
		reloadLyt.setVisibility(View.GONE);

		final PatchedTextView msgContentTv = (PatchedTextView) findViewById(R.id.tv_msg_content);
		final TextView msgTitleTv = (TextView) findViewById(R.id.tv_msg_title);
		final TextView dateTv = (TextView) findViewById(R.id.tv_date);
		dateTv.setVisibility(View.GONE);
		// msgTitleTv.setText(entity.msgTitle);
		// dateTv.setText(entity.date);
		Bundle bundle = getIntent().getExtras();
		String title = bundle
				.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);// 标题
		String content = bundle.getString(JPushInterface.EXTRA_ALERT);// 内容
		if (title != null) {
			msgTitleTv.setText(title);
		} else {
			msgTitleTv.setVisibility(View.GONE);
		}

		if (content != null)
			msgContentTv.setText(content);
		else
			msgContentTv.setText("");

	}
}
